<template>
	<view class="order-list" :class="themeName">

		<view class="order-item">
			<view class="order-item-box">
				<mescroll-uni ref="mescrollRef" @init="mescrollInit" @up="upCallback" :up="upOption" :down="downOption"
					@down="downCallback" :fixed="false" :bottom="0">
					<view class="goods-list">
						<view class="" v-for="(item, index) in bargainGoods" :key="index">
							<view class="bg-white flex code-item">
								<u-image :src="item.image" width="90rpx" height="90rpx" mode="aspectFill"
									radius="6rpx"></u-image>
								<view class="m-l-24 flex-col desc">
									<view class="nr line-1 bold">{{item.title}}</view>
									<view class="m-t-15 flex row-between">
										<view class="xs lighter">{{$zhTran('领取时间')}}：{{item.create_time}}</view>
										<!-- <view class="xs">+100</view> -->
									</view>
								</view>
							</view>
						</view>
					</view>
				</mescroll-uni>
			</view>
			<w-jishuzhichi class="jishuzhichi-nodata" />
		</view>

	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import {
		apiLuckyDrawRecord,
		apiLuckyDrawWinningList
	} from "@/api/luck_draw.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				bargainGoods: [], // 记录列表

				upOption: {
					auto: false, // 不自动加载
					noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
					empty: {
						tip: this.$zhTran('暂无中奖记录~'), // 提示
						icon: this.$getImageUri('resource/image/shopapi/uniapp/empty/order.png'),
						top: '200rpx',
						textColor: '#fff',
					}
				},
				downOption: {
					// textColor: '#fff',
				},
				id: '',
			};
		},

		onShow() {
			this.id = this.$Route.query.id
			this.upCallback({
				num: 1,
				size: 10
			});
		},
		methods: {

			// 上拉加载
			upCallback(page) {
				apiLuckyDrawWinningList({
					page_size: page.size,
					page_no: page.num,
					status: this.status,
					id: this.id,
				}).then(({
					lists,
					count
				}) => {
					if (page.num == 1) this.bargainGoods = [];
					this.bargainGoods.push(...lists);
					this.bargainGoods = this.$zhTran(this.bargainGoods)
					this.mescroll.endSuccess(lists.length, count);
				}).catch(() => {
					this.mescroll.endErr()
				})
			}
		},
		onLoad() {
			// this.id = 2
			if (this.$Route.meta.atitle) {
				uni.setNavigationBarTitle({
					title: this.$zhTran(this.$Route.meta.atitle)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		height: 100%;
		padding: 0;
	}

	.order-list {
		height: 100%;
		display: flex;
		flex-direction: column;

		.order-item {
			flex: 1;
			min-height: 0;

			.order-item-box {
				height: calc(100vh - 100rpx - constant(safe-area-inset-bottom));
				height: calc(100vh - 100rpx - env(safe-area-inset-bottom));
			}
		}
	}

	.goods-list {
		margin: 0 20rpx;
		// margin-top: 20rpx;

		.code-item {
			margin-top: 20rpx;
			padding: 26rpx 24rpx;
		}

		.desc {
			width: 550rpx;
		}
	}
</style>